package com.oreilly.ez.base;


//import com.google.common.cache.CacheBuilder;

import org.springframework.cache.CacheManager;
import org.springframework.cache.support.SimpleCacheManager;
import org.springframework.context.annotation.Bean;

//import org.springframework.cache.concurrent.ConcurrentMapCache;
//import org.springframework.cache.guava.GuavaCache;
//import java.time.Duration;

//@Configuration
//@EnableCaching
public class DefaultCacheConfig {


    @Bean
    public CacheManager cacheManager() {

        SimpleCacheManager simpleCacheManager = new SimpleCacheManager();
//        simpleCacheManager.setCaches(Arrays.asList(
//                new ConcurrentMapCache("personList"),
//                new ConcurrentMapCache("person")
//
//                ));

//        simpleCacheManager.setCaches(Arrays.asList(
//
//
//                //CacheBuilder构建多个cache
//                new GuavaCache(
//                        "personList",//定义cache名称:@Cacheable的cacheNames(等价value)属性要和此对应
//                        CacheBuilder
//                                .newBuilder()
//                                .expireAfterWrite(1, TimeUnit.HOURS)//参数:过期时长、单位
//                                .build()
//                ),
//                new GuavaCache(
//                        "person",
//                        CacheBuilder
//                                .newBuilder()
//                                .expireAfterWrite(5, TimeUnit.MINUTES)
//                                .build()
//                )
//        ));


        return simpleCacheManager;

    }

}
